home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / UNIXLIB37B / test / c / memtest < prev    next >
Text File  |  1991-06-10  |  621b  |  36 lines

  1. #include <stdlib.h>
  2. #include <time.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5.  
  6. static char *s,*d;
  7.  
  8. static void memtest(void)
  9. {
  10. register clock_t t;
  11. register int i;
  12.  
  13. t = clock();
  14. for (i = 0; i < 2048; i++)
  15.   memcpy(d + (rand() & 3),s + (rand() & 3),rand() & 2047);
  16. t = clock() - t;
  17.  
  18. printf("%d.%02d\n",t / CLK_TCK,t % CLK_TCK);
  19. }
  20.  
  21. int main(int argc,char **argv)
  22. {
  23. int i,n;
  24.  
  25. if (argc != 2) { puts("usage: memtest ntest"); exit(1); }
  26.  
  27. n = atoi(argv[1]);
  28.  
  29. if (!(s = malloc(2048))) { perror("malloc()"); exit(1); }
  30. if (!(d = malloc(2048))) { perror("malloc()"); exit(1); }
  31.  
  32. srand(time(0));
  33.  
  34. for (i = 0; i < n; i++) memtest();
  35. }
  36.